/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package vn.aptech.project.view.until;

import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import org.jvnet.substance.skin.SubstanceOfficeBlue2007LookAndFeel;



/**
 *
 * @author admin
 */
public class FormUtil {

    public static void setNativeLookAndFeel(JFrame frame) {
        try {
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
            SwingUtilities.updateComponentTreeUI(frame);
        } catch (Exception e) {
            e.printStackTrace();
            System.out.println("Error setting native LAF: " + e);
        }
    }

    public static void setOfficeLookAndFeel(JFrame frame) {
        try {
            UIManager.setLookAndFeel(new SubstanceOfficeBlue2007LookAndFeel());
            SwingUtilities.updateComponentTreeUI(frame);
        } catch (Exception e) {
            e.printStackTrace();
            System.out.println("Error setting native LAF: " + e);
        }
    }

    public static void setConfirmOnClose(final JFrame frame) {
        frame.addWindowListener(new WindowAdapter() {

            @Override
            public void windowClosing(WindowEvent e) {
                int close = JOptionPane.showConfirmDialog(frame,
                        "You are close window. Are you sure you want to continue?", "Confirm close", JOptionPane.YES_NO_OPTION);
                if (close == JOptionPane.YES_OPTION) {
                    frame.dispose();
                }
            }
        });
    }

    public static void showMessage(String message, JFrame frame) {
        JOptionPane.showMessageDialog(frame,
                        message,"Thông báo", JOptionPane.OK_OPTION);
    }
}
